home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-03 / qb3db.zip / QBDB3.DOC < prev    next >
Text File  |  1993-01-04  |  20KB  |  929 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.                      QuickBASIC (tm) DBASE III (tm) Routines
  25.  
  26.                           Programming Toolbox routines
  27.                                        For
  28.                             QuickBASIC (tm) compiler
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.                                    Written by
  40.  
  41.                                  George Quinones
  42.                                   P.O.Box 1062
  43.                              Orlando,Fl.,32802-1062
  44.                                   (305)894-0023
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.              Copyright (c) 1987 by G. Quinones. all rigths reserved 
  52.  
  53.  
  54.  
  55.      QuickBASIC is a register trademark of MICROSOFT inc.
  56.      DBASE III is a register trademark of ASHTON TATE inc.
  57.  
  58.                          Quick Basic DBASE III Routines
  59.  
  60.                                   INTRODUCTION
  61.  
  62.  
  63.  
  64.  
  65.           This  tool  box  was  designed  to  give  the basic programmer the
  66.      ability to access DBASE III database files, (.DBF).   Just  about every
  67.      file operation is supported with the exception of memo fields and index
  68.      files.  I am currently working in the routines  to access  memo fields,
  69.      in addition  error checking,  which do  not exist  in any of these demo
  70.      subroutines.
  71.  
  72.           Four files are supplied with in this archive:
  73.  
  74.                QBDB3.EXE      A  demo  program  showing  the  used   of  the
  75.                               subroutines.
  76.  
  77.                QBDB3.BAS      Source code  for the demo programm. The source
  78.                               code for the demo  program  is  included  as a
  79.                               sample on  how to  use the  routines.  Some of
  80.                               the  called  modules  used  by  the  demo  are
  81.                               copyrighted by  other companies,  so I can not
  82.                               release their source code.
  83.  
  84.                QBDB3.DOC      Documentation of the QBDB3 subroutines
  85.  
  86.                QBDB3IO.OBJ    This file contains all  the necessary routines
  87.                               to  access  DBASE  III  .DBF files.  This file
  88.                               consist of 10 file  operations subprograms and
  89.                               1  field  operation  subprogram.    All of the
  90.                               Subroutine  have  been  compiled  to  use  the
  91.                               BRUN30.EXE module.
  92.  
  93.           Some limitations have been built into the demo toolbox:
  94.  
  95.                1)        A maximum of 10 fields per record can be access
  96.                2)        A maximum of 50 records per databes file.
  97.  
  98.           By  establishing  these  limitations  it  will  ensure me that any
  99.      person that finds this library usefull will in fact register.
  100.  
  101.           All the routines have been tested and found bug free  when used in
  102.      accordance with  their documentation.   If  you find  that any of these
  103.      routines do not work properly as  described, please  let me  know and I
  104.      will fix them promptly.
  105.  
  106.           All the  above routines  are being  supplied as is.  I do not make
  107.      any implicit or explicit  guaranties that  they will  work, and further
  108.      more will  not assumed  any responsability  for the  used or misused of
  109.      routines included within.
  110.  
  111.                          Quick Basic DBASE III Routines
  112.  
  113.                                OPEN DBASE III FILE
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.      Purpose:            Opens A DBASE III .DBF file for processing
  121.  
  122.      Syntax :            SUB DB.OPEN(         _
  123.                              DB.FX.%,         _
  124.                              DB.FX.NAME.$,    _
  125.                              DB.FIELDS.%,     _
  126.                              DB.LAST.OPEN.$,  _
  127.                              DB.HDR.LEN.%,    _
  128.                              DB.HDR.REC.TOT.!,_
  129.                              DB.LEN.%)
  130.  
  131.      Parameters:         DB.FX.%             Contains the file number of the
  132.                                              file to be opened.
  133.  
  134.                          DB.FX.NAME.$        Contains  the  name of the file
  135.                                              to  be  opened  for  processing
  136.                                              must have a .DBF.
  137.  
  138.                          DB.FIELDS.%         Number of fields in the record.
  139.  
  140.                          DB.LAST.OPEN.$      Last date the file was used.
  141.  
  142.                          DB.HDR.LEN.%        Length of the header structure.
  143.                                              !!DO NOT MODIFIED THIS FIELD!!!
  144.  
  145.                          DB.HDR.REC.TOT.!    Number of records in the file.
  146.  
  147.                          DB.LEN.%            Record Length.
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.                                           1
  173.  
  174.                          Quick Basic DBASE III Routines
  175.  
  176.                               CLOSE DBASE III FILE
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.      Purpose:            Closes a DBASE III .DBF.
  184.  
  185.      Syntax:             SUB DB.CLOSE(           _
  186.                              DB.FX.%,            _          
  187.                              DB.FX.NAME.$,       _
  188.                              DB.HDR.REC.TOT.!,   _
  189.                              DB.RC.%)
  190.  
  191.      Parameters:         DB.FX.%             Contains the file number of the
  192.                                              file to be opened.
  193.  
  194.                          DB.FX.NAME.$        Contains the name  of  the file
  195.                                              to  be  opened  for  processing
  196.                                              must have a .DBF.
  197.  
  198.                          DB.HDR.REC.TOT.!    Number of records in the file.
  199.  
  200.                          DB.RC.%             Return Code.  !!!NOT IN USE!!!!
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.                                           2
  236.  
  237.                          Quick Basic DBASE III Routines
  238.  
  239.                       RETRIEVE STRUCTURE OF DBASE III FILE
  240.  
  241.  
  242.  
  243.  
  244.  
  245.      Purpose:            Retrieves DBASE III .DBF file Structure.
  246.  
  247.      Syntax:             SUB DB.STRUC(      _
  248.                              DB.FX.%,       _
  249.                              DB.FX.NAME.$,  _
  250.                              DB.NAME.$(),   _
  251.                              DB.LENGTH.%(), _
  252.                              DB.TYPE.$(),   _
  253.                              DB.DEC.%(),    _ 
  254.                              DB.FIELDS.%,   _
  255.                              DB.LEN.%,      _
  256.                              DB.RC.%)
  257.  
  258.      Parameters:         DB.FX.%             Contains the file number of the
  259.                                              file to be opened.
  260.  
  261.                          DB.FX.NAME.$        Contains  the  name of the file
  262.                                              to  be  opened  for  processing
  263.                                              must have a .DBF.
  264.  
  265.                          DB.NAME.$()         Array  containing  the names of
  266.                                              the database record fields.
  267.  
  268.                          DB.LENGTH.$()       Array containing  the length of
  269.                                              the database fields.
  270.  
  271.                          DB.TYPE.$()         Array  containing  the  type of
  272.                                              the database fields.
  273.  
  274.                          DB.DEC.$()          Array  containing  the  decimal
  275.                                              positions   of   the   database
  276.                                              fields.
  277.  
  278.                          DB.FIELDS.%         Number   of   fields   in   the
  279.                                              database record.
  280.  
  281.                          DB.LEN.%            Record Length.
  282.  
  283.                          DB.RC.%             Return Code.  !!!NOT IN USE!!!!
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.                                           3
  299.  
  300.                          Quick Basic DBASE III Routines
  301.  
  302.                               CREATE DBASE III FILE
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.      Purpose:            Creates  the  header  structure  of a new DBASE III
  310.                          .DBF file.
  311.  
  312.      Syntax:             SUB DB.CREATE(          _
  313.                              DB.FX.%,            _
  314.                              DB.FX.NAME.$,       _
  315.                              DB.NAME.$(),        _
  316.                              DB.LENGTH.%(),      _
  317.                              DB.TYPE.$(),        _
  318.                              DB.DEC.%(),         _
  319.                              DB.FIELDS.%,        _
  320.                              DB.LEN.%,           _
  321.                              DB.RC.%)
  322.  
  323.      Parameters:         DB.FX.%             Contains the file number of the
  324.                                              file to be opened.
  325.  
  326.                          DB.FX.NAME.$        Contains  the  name of the file
  327.                                              to  be  opened  for  processing
  328.                                              must have a .DBF.
  329.  
  330.                          DB.NAME.$()         Array  containing  the names of
  331.                                              the database record fields.
  332.  
  333.                          DB.LENGTH.$()       Array containing  the length of
  334.                                              the database fields.
  335.  
  336.                          DB.TYPE.$()         Array  containing  the  type of
  337.                                              the database fields.
  338.  
  339.                          DB.DEC.$()          Array  containing  the  decimal
  340.                                              positions   of   the   database
  341.                                              fields.
  342.  
  343.                          DB.FIELDS.%         Number   of   fields   in   the
  344.                                              database record.
  345.  
  346.                          DB.LEN.%            Record Length.
  347.  
  348.                          DB.RC.%             Return Code.  !!!NOT IN USE!!!!
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.                                           4
  362.  
  363.                          Quick Basic DBASE III Routines
  364.  
  365.                               READ DBASE III RECORD
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.      Purpose:            Retrieves a DBASE III by record number.
  373.  
  374.      Syntax:             SUB DB.GET(             _
  375.                              DB.FX.%,            _
  376.                              DB.NUM.%,           _
  377.                              DB.LEN.%,           _
  378.                              DB.HDR.LEN.%,       _
  379.                              DB.HDR.REC.TOT.!) 
  380.  
  381.      Parameters:         DB.FX.%             Contains the file number of the
  382.                                              file to be opened.
  383.  
  384.                          DB.NUM.%            Contains the  record  number of
  385.                                              the   database   record  to  be
  386.                                              retrieve.
  387.  
  388.                          DB.LEN.%            Record Length.
  389.  
  390.                          DB.HDR.LEN.%        Length of the header structure.
  391.                                              !!DO NOT MODIFIED THIS FIELD!!!
  392.  
  393.                          DB.HDR.REC.TOT.!    Number of records in the file.
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.                                           5
  425.  
  426.                          Quick Basic DBASE III Routines
  427.  
  428.                              UPDATE DBASE III RECORD
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.      Purpose:            Updates a DBASE III record by record number
  436.  
  437.      Syntax:             SUB DB.PUT(             _
  438.                              DB.FX.%,            _
  439.                              DB.NUM.%,           _
  440.                              DB.LEN.%,           _
  441.                              DB.HDR.LEN.%,       _
  442.                              DB.HDR.REC.TOT.!)
  443.  
  444.      Parameters:         DB.FX.%             Contains the file number of the
  445.                                              file to be opened.
  446.  
  447.                          DB.NUM.%            Contains  the  record number of
  448.                                              the  database   record   to  be
  449.                                              retrieve.
  450.  
  451.                          DB.LEN.%            Record Length.
  452.  
  453.                          DB.HDR.LEN.%        Length of the header structure.
  454.                                              !!DO NOT MODIFIED THIS FIELD!!!
  455.  
  456.                          DB.HDR.REC.TOT.!    Number of records in the file.
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470.  
  471.  
  472.  
  473.  
  474.  
  475.  
  476.  
  477.  
  478.  
  479.  
  480.  
  481.  
  482.  
  483.  
  484.  
  485.  
  486.  
  487.                                           6
  488.  
  489.                          Quick Basic DBASE III Routines
  490.  
  491.                              APPEND DBASE III RECORD
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498.      Purpose:            Adds a DBASE III record.
  499.  
  500.      Syntax:             SUB DB.ADD(             _
  501.                              DB.FX.%,            _
  502.                              DB.NUM.%,           _
  503.                              DB.LEN.%,           _
  504.                              DB.HDR.LEN.%,       _
  505.                              DB.HDR.REC.TOT.!)
  506.  
  507.      Parameters:         DB.FX.%             Contains the file number of the
  508.                                              file to be opened.
  509.  
  510.                          DB.NUM.%            Contains the  record  number of
  511.                                              the   database   record  to  be
  512.                                              retrieve.
  513.  
  514.                          DB.LEN.%            Record Length.
  515.  
  516.                          DB.HDR.LEN.%        Length of the header structure.
  517.                                              !!DO NOT MODIFIED THIS FIELD!!!
  518.  
  519.                          DB.HDR.REC.TOT.!    Number of records in the file.
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540.  
  541.  
  542.  
  543.  
  544.  
  545.  
  546.  
  547.  
  548.  
  549.  
  550.                                           7
  551.  
  552.                          Quick Basic DBASE III Routines
  553.  
  554.                              DELETE DBASE III RECORD
  555.  
  556.  
  557.  
  558.  
  559.  
  560.  
  561.      Purpose:            Marks a record a DBASE III record for deletion.
  562.  
  563.      Syntax:             SUB DB.DEL(             _
  564.                              DB.FX.%,            _
  565.                              DB.NUM.%,           _
  566.                              DB.LEN.%,           _
  567.                              DB.HDR.LEN.%,       _
  568.                              DB.HDR.REC.TOT.!)
  569.  
  570.      Parameters:         DB.FX.%             Contains the file number of the
  571.                                              file to be opened.
  572.  
  573.                          DB.NUM.%            Contains  the  record number of
  574.                                              the  database   record   to  be
  575.                                              retrieve.
  576.  
  577.                          DB.LEN.%            Record Length.
  578.  
  579.                          DB.HDR.LEN.%        Length of the header structure.
  580.                                              !!DO NOT MODIFIED THIS FIELD!!!
  581.  
  582.                          DB.HDR.REC.TOT.!    Number of records in the file.
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.  
  602.  
  603.  
  604.  
  605.  
  606.  
  607.  
  608.  
  609.  
  610.  
  611.  
  612.  
  613.                                           8
  614.  
  615.                          Quick Basic DBASE III Routines
  616.  
  617.                  CONVERT RELATIVE RECORD # TO ABSOLUTE RECORD #
  618.  
  619.  
  620.  
  621.  
  622.  
  623.  
  624.      Purpose:            Finds data base physical record number
  625.  
  626.      Syntax:             SUB  DB.FIND.DB.REC(       _
  627.                                 DB.NUM.%,           _
  628.                                 DB.LEN.%,           _
  629.                                 DB.HDR.LEN.%,       _
  630.                                 DB.HDR.REC.TOT.!,   _
  631.                                 DB.RECNUM.!,        _ 
  632.                                 DB.L.%,             _
  633.                                 DB.R.%)
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666.  
  667.  
  668.  
  669.  
  670.  
  671.  
  672.  
  673.  
  674.  
  675.  
  676.                                           9
  677.  
  678.                          Quick Basic DBASE III Routines
  679.  
  680.                              RECALL DBASE III RECORD
  681.  
  682.  
  683.  
  684.  
  685.  
  686.  
  687.      Purpose:            Recalls a DBASE III .DBF record by record number.
  688.  
  689.      Syntax:             SUB DB.RECALL(          _
  690.                              DB.FX.%,            _
  691.                              DB.NUM.%,           _
  692.                              DB.LEN.%,           _
  693.                              DB.HDR.LEN.%,       _
  694.                              DB.HDR.REC.TOT.!)
  695.  
  696.      Parameters:         DB.FX.%             Contains the file number of the
  697.                                              file to be opened.
  698.  
  699.                          DB.NUM.%            Contains the  record  number of
  700.                                              the   database   record  to  be
  701.                                              retrieve.
  702.  
  703.                          DB.LEN.%            Record Length.
  704.  
  705.                          DB.HDR.LEN.%        Length of the header structure.
  706.                                              !!DO NOT MODIFIED THIS FIELD!!!
  707.  
  708.                          DB.HDR.REC.TOT.!    Number of records in the file.
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.  
  731.  
  732.  
  733.  
  734.  
  735.  
  736.  
  737.  
  738.  
  739.                                          10
  740.  
  741.                          Quick Basic DBASE III Routines
  742.  
  743.                                PACK DBASE III FILE
  744.  
  745.  
  746.  
  747.  
  748.  
  749.  
  750.      Purpose:            Removes all records marks  for deletion  in a DBASE
  751.                          III .DBF file.
  752.  
  753.      Syntax:             SUB DB.PACK(            _
  754.                              DB.FX.%,            _
  755.                              DB.LEN.%,           _
  756.                              DB.HDR.LEN.%,       _
  757.                              DB.HDR.REC.TOT.!)
  758.  
  759.      Parameters:         DB.FX.%             Contains the file number of the
  760.                                              file to be opened.
  761.  
  762.                          DB.NUM.%            Contains the  record  number of
  763.                                              the   database   record  to  be
  764.                                              retrieve.
  765.  
  766.                          DB.LEN.%            Record Length.
  767.  
  768.                          DB.HDR.LEN.%        Length of the header structure.
  769.                                              !!DO NOT MODIFIED THIS FIELD!!!
  770.  
  771.                          DB.HDR.REC.TOT.!    Number of records in the file.
  772.  
  773.  
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.  
  797.  
  798.  
  799.  
  800.  
  801.  
  802.                                          11
  803.  
  804.                          Quick Basic DBASE III Routines
  805.  
  806.                             CONVERT NUMBER TO STRING
  807.  
  808.  
  809.  
  810.  
  811.  
  812.  
  813.      Purpose:            Convert a double precision number into  a string so
  814.                          it can be used by DBASE III.
  815.  
  816.      Syntax:             SUB DB.NUM.STR(    _  
  817.                              DB.NUM.#,      _       
  818.                              DB.DEC.%,      _
  819.                              DB.STR.NUM$)
  820.  
  821.      Parameters:         DB.NUM.#            Contains    the    number    to
  822.                                              converted to a string.
  823.  
  824.                          DB.DEC.%            Contains the  number of decimal
  825.                                              position that the number should
  826.                                              contain.
  827.  
  828.                          DB.STR.NUM.$        Number converted to string.
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.  
  863.  
  864.  
  865.                                          12
  866.  
  867.                          Quick Basic DBASE III Routines
  868.  
  869.                                    ORDER FORM
  870.  
  871.  
  872.  
  873.  
  874.  
  875.  
  876.      NAME                     ________________________________________
  877.  
  878.      ADDRESS                  ________________________________________
  879.  
  880.      CITY                     ________________________________________
  881.  
  882.      STATE                    ________________________________________
  883.  
  884.      ZIP CODE                 ______________________
  885.  
  886.      PHONE                    (______)______--________
  887.  
  888.      QuickBasic Ver:          _____________
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.      MAIL TO                  George Quinones
  898.                               P.O.Box 1062
  899.                               Orlando,Fl.,32803-1062
  900.  
  901.  
  902.  
  903.  
  904.      Make check for $20.00  payable to  George Quinones.   Please  allow 2-3
  905.      weeks for delivery
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.                                          13
  929.